import org.deschutter.dump.AllianceDump;
import org.deschutter.dump.GalaxyDump;
import org.deschutter.dump.PlanetDump;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;

import java.util.Date;
import java.math.BigDecimal;

/**
 * User: Berten De Schutter
 * Date: 06-Jul-2009
 * Time: 13:05:07
 * <p/>
 * The Digger is used For:
 * 1) Getting PlanetDumps (org.deschutter.planet)
 * 2) Getting GalaxyDumps (org.deschutter.galaxy
 * 3) Getting AllianceDumps (org.deschutter.alliance)
 */
public class Digger {

    public static void main(String[] args) throws Exception {
        SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();

        Scheduler sched = schedFact.getScheduler();

        sched.start();

        // Planet Dump
        JobDetail jobDetailPlanet = new JobDetail("Planet Dump",
                null,
                PlanetDump.class);


        java.util.Calendar cal = new java.util.GregorianCalendar((new BigDecimal(args[0])).intValue(), (new BigDecimal(args[1])).intValue(), (new BigDecimal(args[2])).intValue());
        cal.set(cal.HOUR, (new BigDecimal(args[3])).intValue());
        cal.set(cal.MINUTE, (new BigDecimal(args[4])).intValue());
        cal.set(cal.SECOND, (new BigDecimal(args[5])).intValue());
        cal.set(cal.MILLISECOND, 0);

        Date startTime = cal.getTime();

        SimpleTrigger trigger = new SimpleTrigger("Planet Dump",
                null,
                startTime,
                null,
                SimpleTrigger.REPEAT_INDEFINITELY,
                3600L * 1000L);


        sched.scheduleJob(jobDetailPlanet, trigger);
        // Galaxy Dump

        JobDetail jobDetailGalaxy = new JobDetail("Galaxy Dump",
                null,
                GalaxyDump.class);


        cal = new java.util.GregorianCalendar((new BigDecimal(args[0])).intValue(), (new BigDecimal(args[1])).intValue(), (new BigDecimal(args[2])).intValue());
        cal.set(cal.HOUR, (new BigDecimal(args[3])).intValue());
        cal.set(cal.MINUTE, (new BigDecimal(args[4])).intValue());
        cal.set(cal.SECOND, (new BigDecimal(args[5])).intValue());
        cal.set(cal.MILLISECOND, 0);

        startTime = cal.getTime();

        SimpleTrigger triggerGal = new SimpleTrigger("Galaxy Dump",
                null,
                startTime,
                null,
                SimpleTrigger.REPEAT_INDEFINITELY,
                3600L * 1000L);


        sched.scheduleJob(jobDetailGalaxy, triggerGal);

        // Alliance Dump

        JobDetail jobDetailAlliance = new JobDetail("Alliance Dump",
                null,
                AllianceDump.class);


        cal = new java.util.GregorianCalendar((new BigDecimal(args[0])).intValue(), (new BigDecimal(args[1])).intValue(), (new BigDecimal(args[2])).intValue());
        cal.set(cal.HOUR, (new BigDecimal(args[3])).intValue());
        cal.set(cal.MINUTE, (new BigDecimal(args[4])).intValue());
        cal.set(cal.SECOND, (new BigDecimal(args[5])).intValue());
        cal.set(cal.MILLISECOND, 0);

        startTime = cal.getTime();

        SimpleTrigger triggerAlly = new SimpleTrigger("Alliance Dump",
                null,
                startTime,
                null,
                SimpleTrigger.REPEAT_INDEFINITELY,
                3600L * 1000L);


        sched.scheduleJob(jobDetailAlliance, triggerAlly);
    }

}
